package classmatego

import (
	"fmt"

	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

func init() {

}
func DBDEmo() {
	dsn := "root:123456@tcp(172.14.1.84:3306)/classmates?charset=utf8"
	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		fmt.Println("连接数据库失败,原因是:", err.Error())
		return
	}
	fmt.Println("连接成功", db)
}
    return db
    var tanjj Classmate
    tanjj.Name = "谈jj"
    tanjj.Sex = "女"l
    tanjj.Sn = "123456"
    tx := db.Save(&tanjj)
    fmt.Println(tx)
     

func Login() bool {
	var name string
	fmt.Println("请输入用户名")
	fmt.Scanln(&name)
	var pswd string
	fmt.Println("请输入密码:")
		fmt.Scanln(&pswd)
		var user Classmate
		db.Where("name = ?", name).First(&user)
		if user.Pswd == pswd {
			fmt.Println("登陆成功")
			var yzh Classmate
			var findname string
			fmt.Println("请在次输入名字查看其它信息")
			fmt.Scanln(&findname)
			db.Where("name=?", findname).First(&yzh)
			fmt.Println(yzh.Name)
			fmt.Println(yzh.Sn)
			fmt.Println(yzh.Classname)
			fmt.Println(yzh.Ip)
			fmt.Println(yzh.Sex)

		} else {
			fmt.Println("登陆失败")
			fmt.Println(user.Pswd)
			fmt.Println(pswd)
		}
	}
 	for {
	var yzh Classmate
 	var findname string
 	fmt.Println("请输入你要查找的人的名字")
	fmt.Scanln(&findname)
 	db.Where("name=?", findname).First(&yzh)
 	fmt.Println(yzh.Name)
 	fmt.Println(yzh.Sn)
    fmt.Println(yzh.Classname)
 	return true
 } else {
 	fmt.Println("登陆失败")
 	return false
}

func findTop10()
